package com.源码分析.thread;

import java.util.Random;

import org.junit.Test;

import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;

public class ParallelDemo {

	Random d = new Random(7);

	@Test
	public void test() {
		Flux.range(1, 50)
		.parallel()
		.runOn(Schedulers.parallel()) // 必须要配合runOn()，否则就是当前线程顺序执行
        .map(v -> v + 1)
        .filter(t -> true)
        .subscribe(x -> {
        	System.out.println(Thread.currentThread().getName() + ": " + x);
        });
	}

}
